package com.py.androidUtils.base;

import java.util.ArrayList;
import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class BaseCommAdapter<T> extends BaseAdapter {
	protected List<Object> listData = new ArrayList<Object>();

	/**
	 * 设置数据
	 * 
	 * @param listData
	 */
	public void setList(List<T> listData) {
		if (listData != null && listData.size() > 0) {
			this.listData.addAll(listData);
		}
		notifyDataSetChanged();
	}

	/**
	 * 添加数据
	 * 
	 * @param alObjects
	 */
	public void addObject(Object alObjects) {
		if (null != alObjects) {
			this.listData.add(alObjects);
			notifyDataSetChanged();
		}
	}

	/**
	 * 清理数据
	 */
	public void clear() {
		this.listData.clear();
		notifyDataSetChanged();
	}

	public List<Object> getListData() {
		return listData;
	}

	public void setListData(List<Object> listData) {
		this.listData = listData;
	}

	@Override
	public int getCount() {
		return listData == null ? 0 : listData.size();
	}

	@Override
	public Object getItem(int position) {
		return listData == null ? null : listData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return listData == null ? 0 : position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return null;
	}

}
